import sqlite3

# Connect to the SQLite database
conn = sqlite3.connect('config.db')
c = conn.cursor()

# Create the defects table if it doesn't exist
c.execute('''
    CREATE TABLE IF NOT EXISTS defects (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        defect_type TEXT NOT NULL,
        severity REAL NOT NULL,
        notification_method TEXT NOT NULL,
        notify_to TEXT NOT NULL,
        image_path TEXT,
        detected_at DATETIME
    )
''')

# Insert sample data into the defects table
c.execute('''
    INSERT INTO defects (defect_type, severity, notification_method, notify_to, image_path, detected_at)
    VALUES ('Crazing', 0.9, 'Email', 'admin@example.com', 'uploads/crazing_2.jpg', '2025-07-04 10:00:00')
''')

# Commit changes and close the connection
conn.commit()
conn.close()
